package com.hotinno.feedmonitor.web.guest;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.hotinno.feedmonitor.dao.guest.Guest;
import com.hotinno.feedmonitor.dao.guest.GuestDao;


@Controller
public class GuestController {
	@Autowired
	private GuestDao guestDao;

	@RequestMapping(value = "/guest")
	public ModelAndView guestbook(HttpServletRequest request) {
		// Handle a new guest (if any):
		String name = request.getParameter("name");
		if (name != null)
			guestDao.persist(new Guest(name));
		// Prepare the result view (guest.jsp):
		return new ModelAndView("guest", "guestDao", guestDao);
	}
}
